/* ====================================== */
/** idem que sur lautre depot **/
/* ====================================== */
package edu.imac.angryfood.component;

import javax.swing.Timer;

import org.newdawn.slick.SlickException;

import edu.imac.angryfood.world.World;

/** Nothing happens with this projectile when the user clicks and it is still in the air */

public class SimpleProjectile extends AbstractProjectile {

	/** constructor for circle projectiles
	 * 
	 * @param x x position of the projectile
	 * @param y y position of the projectile
	 * @param radius radius of the projectile
	 * @param droped if the projectile has already been droped
	 * @param num the order in which the projectile will be launched
	 * @param image the name of the image's file
	 */
	
	public SimpleProjectile(int x, int y, float radius, boolean droped, int num, String image)
			throws SlickException {
		super(x, y, radius, droped, num, image);
		// TODO Auto-generated constructor stub
	}
	
	/** constructor for rectangle projectiles
	 * 
	 * @param x x position of the projectile
	 * @param y y position of the projectile
	 * @param width width of the projectile
	 * @param height height of the projectile
	 * @param droped if the projectile has already been droped
	 * @param num the order in which the projectile will be launched
	 * @param image the name of the image's file
	 */
	
	public SimpleProjectile(int x, int y, int width, int height, boolean droped, int num, String image)
			throws SlickException {
		super(x, y, width, height, droped, num, image);
		// TODO Auto-generated constructor stub
	}

	/** when the user clicks, nothing happens
	 * 
	 * @param world the world that contains the game
	 * @throws SlickException
	 */
	
	@Override
	public void click(World world) throws SlickException {
		if (tLaunched instanceof Timer){
			tLaunched.stop();
		}
		clicked=true;
		next(world);
	}

	/** when the projectile collides something, nothing happens
	 * 
	 * @param world the world that contains the game
	 */
	@Override
	public void collision(World world) {
		if (!collided){
			collided=true;
			if (tLaunched instanceof Timer){
				tLaunched.stop();
			}
			clicked=true;	
		}
	}
}
